﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VPC.BO;
using VPC.BL;

namespace VPC.UI
{
    public partial class AddNewContact : Form
    {
        public AddNewContact()
        {
            InitializeComponent();
        }

        private void addButton_Click(object sender, EventArgs e)
        {
            if (firstNameTextfield.Text != "")
            {
                ContactBO addContact = new ContactBO();

                addContact.FirstName        = firstNameTextfield.Text;
                addContact.LastName         = lastNameTextfield.Text;
                addContact.Fonction         = fonctionTextfield.Text;
                addContact.Compagny         = compagnyTextfield.Text;
                addContact.MobileNumber1    = mobileNumber1Textfield.Text;
                addContact.MobileNumber1    = mobileNumber2Textfield.Text;
                addContact.MobileNumber1    = mobileNumber3Textfield.Text;
                addContact.HomeNumber1      = homeNumber1Textfield.Text;
                addContact.HomeNumber1      = homeNumber2Textfield.Text;
                addContact.HomeNumber1      = homeNumber3Textfield.Text;
                addContact.WorkNumber1      = workNumber1Textfield.Text;
                addContact.WorkNumber1      = workNumber2Textfield.Text;
                addContact.WorkNumber1      = workNumber3Textfield.Text;
                addContact.FaxNumber1       = faxNumber1Textfield.Text;
                addContact.FaxNumber1       = faxNumber2Textfield.Text;
                addContact.FaxNumber1       = faxNumber3Textfield.Text;
                addContact.Street           = streetTextfield.Text;
                addContact.Locality         = localityTextfield.Text;
                addContact.Code             = codeTextfield.Text;
                addContact.Country          = countryTextfield.Text;
                addContact.Email1           = email1Textfield.Text;
                addContact.Email2           = email2Textfield.Text;
                addContact.Email3           = email3Textfield.Text;

                if (ContactBL.AddNewContactDetails(addContact) == 1)
                {
                    MessageBox.Show("Contact has been saved");
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("An error occured during the processe. Please try again");
                    this.Hide();
                }
            }
            else
            {
                MessageBox.Show("You must specify, at least, a first name");
            }

        }

    }
}
